
package com.xifan.myaccount.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xifan.myaccount.R;

import java.util.Arrays;
import java.util.List;

public class DrawerAdapter extends BaseAdapter {
    private Context mContext;
    private List<String> mList;
    
    public DrawerAdapter(Context context) {
        mContext = context;
        mList = Arrays.asList(context.getResources().getStringArray(R.array.drawer_menu_item));
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = View.inflate(mContext, R.layout.view_drawer_list_item, null);
            holder.titleText = (TextView) view.findViewById(R.id.title);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.titleText.setText(mList.get(position));
        return view;
    }

    class ViewHolder {
        TextView titleText;
    }

}
